import { RootStateTypes } from '../types';
import { MutationTree, ActionTree } from 'vuex';

const namespaced = true;
interface stateInterface {
  menu: any[],
  hotPlace: any[]
}
const state: stateInterface = {
  menu: [],
  hotPlace: []
};
const types = {
  MENU: 'MENU',
  HOT_PLACE: 'HOT_PLACE'
};

const mutations: MutationTree<stateInterface> = {
  [types.MENU]: (state, menu: any[]) => {
    state.menu = menu;
  },
  [types.HOT_PLACE]: (state, hotPlace: any[]) => {
    state.hotPlace = hotPlace;
  },
};

const actions: ActionTree<stateInterface, RootStateTypes> = {
  setMenu({ commit }, menu) {
    commit(types.MENU, menu);
  },
  setHotPlace({ commit }, hotPlace) {
    commit(types.HOT_PLACE, hotPlace);
  },
};

export default { namespaced, state, actions, mutations };
